#!/bin/sh

date="$(date +%F)"
tests="vanilla_tor tcp_connect meek_fronted_requests_test"

rm --interactive ooni-index.csv ooni-index.csv.xz

for test in ${tests}
do
    #wget -O ooni-index-${date}-${test}.json \
#	    "https://api.ooni.io/api/v1/files?limit=500000&test_name=${test}"
    xz -v ooni-index-${date}-${test}.json
    xz -dc ooni-index-${date}-${test}.json.xz | ./json2csv >> ooni-index.csv
done

sed -i '1idate,cc,asn,test_name\' ooni-index.csv
xz -v ooni-index.csv

Rscript graphs.R
